<?php
namespace app\channel\model;
use think\Model;
use Think\Db;

class Base extends Model
{
    //显示已打包和H5的游戏提示
    public function gameNotice(){
        $select = Db::name('ViewGameManage')->field('game_id, game_name')
            ->where('status', 1)
            ->order('game_id desc')->select();
        return $select;
    }

    public function channelNotice(){
        $cpsId = session('admin.cps_id');
        $sdkId = session('admin.sdk_id');

        $cpsSelect = [];
        $sdkSelect = [];
        if($cpsId){
            $allChannelId = model('manage/Channel')->allChannelId($cpsId);
            $cpsSelect = Db::name('ViewChannel')
                ->field('cps_id, cps_name')
                ->where('status', 1)
                ->where('cps_id', 'in', $allChannelId)
                ->order('cps_id desc')
                ->select();
        }
        if($sdkId){
            $sdkSelect = Db::name('ViewChannel')
                ->field('channel_id as cps_id, channel_name as cps_name')
                ->where('status', 1)
                ->where('channel_id', $sdkId)
                ->select();
        }
        $select = array_merge($cpsSelect, $sdkSelect);
        return $select;
    }
}